package com.youease.chris.view
{
	import com.youease.chris.manager.GlobalObject;
	
	import mx.containers.HBox;
	import mx.controls.Image;
	import mx.controls.Label;
	import mx.controls.listClasses.ListItemRenderer;
	
	public class TextureRenderer extends ListItemRenderer
	{
		private var hbox:HBox;
		private var img:Image;
		private var labelTxt:Label;
		
		public function TextureRenderer()
		{
			super();
		}
		
//		<mx:HBox verticalAlign="bottom" verticalScrollPolicy="off" horizontalScrollPolicy="off">
//			<mx:Script>
//				<![CDATA[
//					import com.youease.chris.manager.GlobalObject;
//				]]>
//			</mx:Script>
//			<mx:Image width="35" height="35" source="{GlobalObject.projectDir+'/textures/'+data.img}"/>
//			<mx:Label text="{data.img}"/>
//		</mx:HBox>
		
		override protected function createChildren():void {
			super.createChildren();
			hbox = new HBox();
			img = new Image();
			img.width = img.height = 35;
			
			labelTxt = new Label();
			
			hbox.addChild(img);
			hbox.addChild(labelTxt);
			this.addChild(hbox);
		}
		
		override public function set data(value:Object):void {
			super.data = value;
			
		}
		
		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
			super.updateDisplayList(unscaledWidth,unscaledHeight);
			img.source = GlobalObject.projectDir+'/textures/'+data.img;
			labelTxt.text = data.img;
		}
	}
}